﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Extensions;
using JXT.PrimaryKey.Batman.Validation;
using JXT.PrimaryKey.Batman.Collections;
using JXT.PrimaryKey.Batman.Domain.Models;
using JXT.PrimaryKey.Batman.Domain.Services;
using JXT.PrimaryKey.Batman.Domain.Specifications;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Models;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Repositories;

namespace JXT.PrimaryKey.Batman.Domain.UserSystem.Services.Default
{
    public class UserIdentityService : CachedServiceBase<UserIdentity>, IUserIdentityService
    {
        private static readonly string _cacheKey = "list";

        public IEnumerable<UserIdentity> GetList()
        {
            var list = Cache.Get(CacheSpace, _cacheKey) as IEnumerable<UserIdentity>;
            if (list == null)
            {
                list = LoadRepository<IUserIdentityRepository>().GetList(null);
                Cache.Add(CacheSpace, _cacheKey, list, TimeSpan.FromDays(1));
            }
            return list;
        }
    }
}
